package gretha.Jtables;

import gretha.donnees.Massif;
import gretha.modelsDeJTable.MassifTableModel;
import gretha.utils.HeaderListener;

import javax.swing.JTable;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

public class JTableMassif extends JTable {

	private static final long serialVersionUID = -7278908139785194858L;

	public JTableMassif(TableModel dm) {
		super(dm);
		setAutoCreateRowSorter(true);
		TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
				this.getModel());
		setRowSorter(sorter);

		getTableHeader().addMouseListener(
				new HeaderListener(this.getTableHeader()));

	}

	public void supprimerLigne(int selectedRow) {
		((MassifTableModel) getModel()).supprimerLigne(selectedRow);
	}

	public Massif[] getDonnees() {
		return ((MassifTableModel) getModel()).getDonnees();
	}

}
